import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        // 读取输入：红、黄、绿、棕、蓝、粉、黑球的数目
        int red = scanner.nextInt();
        int yellow = scanner.nextInt();
        int green = scanner.nextInt();
        int brown = scanner.nextInt();
        int blue = scanner.nextInt();
        int pink = scanner.nextInt();
        int black = scanner.nextInt();
        
        // 计算最高分彩球的分值
        int maxColorScore = 0;
        if (yellow > 0) maxColorScore = Math.max(maxColorScore, 2);
        if (green > 0) maxColorScore = Math.max(maxColorScore, 3);
        if (brown > 0) maxColorScore = Math.max(maxColorScore, 4);
        if (blue > 0) maxColorScore = Math.max(maxColorScore, 5);
        if (pink > 0) maxColorScore = Math.max(maxColorScore, 6);
        if (black > 0) maxColorScore = Math.max(maxColorScore, 7);
        
        // 红球阶段的得分：红球数量 * (1 + 最高分彩球的分值)
        int redPhaseScore = red * (1 + maxColorScore);
        
        // 彩球阶段的得分：黄*2 + 绿*3 + 棕*4 + 蓝*5 + 粉*6 + 黑*7
        int colorPhaseScore = yellow * 2 + green * 3 + brown * 4 + blue * 5 + pink * 6 + black * 7;
        
        // 总最高分
        int totalScore = redPhaseScore + colorPhaseScore;
        
        System.out.println(totalScore);
        
        scanner.close();
    }
}